{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=68
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	i,n,k,ans,p1,p2:longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
read(p2);
read(p1);
ans:=0;
for i:=3 to n do begin
	read(k);
	if (p1>p2) and (p1>k) then inc(ans);
	p2:=p1;
	p1:=k;
end;
write(ans);
end.